package com.cust.cow.controller;

import com.cust.cow.common.Result;
import com.cust.cow.pojo.pill;
import com.cust.cow.service.PillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("pill")
@CrossOrigin("*")
public class PillController {
    @Autowired
    PillService pillService;

    @RequestMapping("findPillAll")
    public List<pill> findPillAll()
    {
        return pillService.findPillAll();
    }

    @RequestMapping("findPillById")
    public pill findPillByName(Integer pillId)
    {
        return pillService.findPillByName(pillId);
    }

    @PostMapping("insertPill")
    public Result insertPill(@RequestBody pill pill)
    {
        return pillService.insertPill(pill);
    }

    @RequestMapping("deletePill")
    public Result deletePill(@RequestParam("pillId") Integer pillId)
    {
        return pillService.deletePill(pillId);
    }
}
